-- 快速模式台词状态
-- 这个文件定义了快速模式下的台词StateGraph状态

local function CreateSpeedModeBlockedState()
    return State{
        name = "pono_speed_mode_blocked",
        tags = {"busy", "caninterrupt"},
        
        onenter = function(inst)
            -- 【保险措施】确保仍处于加速模式
            if not inst:HasTag("pono_speed_mode") then
                -- 如果意外失去加速模式标签，直接返回idle
                inst.sg:GoToState("idle")
                return
            end
            -- 播放台词
            if inst.components.talker then
                -- 更丰富的随机台词，针对不同情况
                local blocked_phrases = {
                    "太快了喵！","冲刺中不能分心喵！",
                    "跑太快停不下来喵！", "要专心跑步喵！",
                     "全速前进中喵！",
                }
                local phrase = blocked_phrases[math.random(#blocked_phrases)]
                inst.components.talker:Say(phrase)
            end
            
            -- 播放音效（可选）
            if inst.SoundEmitter then
                inst.SoundEmitter:PlaySound("dontstarve/common/destroy_wood")
            end
            
            -- 短暂停顿后结束状态（不退出加速模式）
            inst:DoTaskInTime(0.3, function()
                if inst.sg:HasStateTag("busy") then
                    inst.sg:GoToState("idle")
                end
            end)
        end,
        
        timeline = {
            -- 0.3秒后自动结束
            TimeEvent(0.3, function(inst)
                inst.sg:GoToState("idle")
            end)
        },
        
        events = {
            EventHandler("animover", function(inst) 
                inst.sg:GoToState("idle") 
            end),
        },
        
        onexit = function(inst)
        end,
    }
end

-- 添加状态到StateGraph
AddStategraphPostInit("wilson", function(sg)
    sg.states["pono_speed_mode_blocked"] = CreateSpeedModeBlockedState()
end)

AddStategraphPostInit("wilson_client", function(sg) 
    sg.states["pono_speed_mode_blocked"] = CreateSpeedModeBlockedState()
end)
